﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CheckDestroy : MonoBehaviour {

	bool isDestroy = false;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () 
	{
		CheckNeedDestroy();
	}

	void CheckNeedDestroy()
	{
		if(!isDestroy)
		{
			if(Camera.main.WorldToViewportPoint(transform.position).y < 0)
			{
				// Debug.Log(Camera.main.WorldToViewportPoint(transform.position).ToString());
				CreateItem.Instance.objCount--;
				Destroy(this);
				gameObject.SetActive(false);

				isDestroy = true;

				// Debug.Log("========= Need Destroy this");
			}
		}
	}
}
